<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()

const onClickLeft = () => {
  // console.log('点击左侧')
  // 返回上一个页面
  if (history.state.back) {
    router.back()
  } else {
    router.push('/')
  }
}
const onClickRight = () => {
  emit('click-right')
}
//父传子
defineProps<{
  title?: string
  rightText?: string
}>()
const emit = defineEmits<{
  (e: 'click-right'): void
}>()
</script>
<template>
  <van-nav-bar
    :title="title"
    :right-text="rightText"
    fixed
    left-arrow
    @click-left="onClickLeft"
    @click-right="onClickRight"
  />
</template>
<style lang="scss" scoped></style>
